package it.agm.fanta.adapter;

import it.agm.fanta.R;
import it.agm.fanta.model.NavItem;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class NavDrawerAdapter extends ArrayAdapter<NavItem> {
	
	public NavDrawerAdapter(Context context, int textViewResourceId,
			ArrayList<NavItem> objects) {
        super(context, textViewResourceId, objects);
    }

	@Override
    public View getView(int position, View convertView, ViewGroup parent) {
		
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.drawer_list_item, null);
        TextView item = (TextView)convertView.findViewById(R.id.textItem);
        ImageView imageItem = (ImageView)convertView.findViewById(R.id.imageItem);
       
        NavItem navItem = getItem(position);
        
        item.setText(navItem.getText());
        imageItem.setImageDrawable(navItem.getImage());
        
        return convertView;
    }
	
	

}
